'use client'; // Error components must be Client Components

import Head from 'next/head';
import { useEffect } from 'react';

export default function GlobalError({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    console.group(
      '%cError',
      'padding: 2px 5px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;'
    );
    console.log(error);
    console.groupEnd();
    console.error(error);
  }, [error]);

  return (
    <html lang="en">
      <Head>
        <title>ERROR</title>
      </Head>
      <body>
        <div className="flex justify-center items-center w-full h-full">
          <div>
            <h2 className="text-3xl font-bold">Something went wrong!</h2>
            <a onClick={() => reset?.()}>Try again</a>
          </div>
        </div>
      </body>
    </html>
  );
}
